/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package eit.service.dao.impl;

import eit.model.* ;
import eit.service.dao.IssueDAO;
import java.util.ArrayList;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

/**
 *
 * @author acoustic
 */

@Component

public class IssueDAOImpl implements IssueDAO
{
	private DataSource AppDataSource ;
	
	@Autowired
	private JdbcTemplate IssueJDBCTemplate ;

		
	public void setJdbcTemplate(JdbcTemplate _JdbcTemplate)
	{
		this.IssueJDBCTemplate = _JdbcTemplate ;
	}

	@Override
	public void insert(Issue _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public void update(Issue _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public void delete(Issue _Item)
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}

	@Override
	public Issue get(int _ID)
	{
		String SQLQuery = 
				"SELECT I.ID, I.Title, I.Description, I.CategoryID, I.Type, C.ProjectID "
				+ "FROM issue I "
				+ "INNER JOIN category C ON I.CategoryID = C.ID "
				+ "WHERE I.ID = ?" ;
		
		Issue ReturnIssue = 
				(Issue) this.IssueJDBCTemplate.queryForObject(SQLQuery, new Object[]{_ID}, new IssueRowMapper()) ;
		
		//ReturnIssue.setProjectID(this.getProjectIDByCategory(ReturnIssue.getCategoryID()));
		
		//ReturnIssue.setTagIDs(this.GetTagListByIssue(ReturnIssue.getID()));
		
		return ReturnIssue;
	}

	@Override
	public ArrayList<Issue> getList()
	{
		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
	}
	
	
}
